package com.young.springdemo.service.singleton;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class TestSingleton {

//    @PostConstruct
    public void test(){
        EagerSingleton instance = EagerSingleton.getInstance();
        EagerSingleton instance1 = EagerSingleton.getInstance();
        EagerSingleton instance2 = EagerSingleton.getInstance();
        System.out.println("===="+(instance == instance1));
        System.out.println(instance1 == instance2);

        for (int i = 0 ;i<10;i++){
            LazySingleton instance3 = LazySingleton.getInstance();
            LazySingleton instance4 = LazySingleton.getInstance();
            System.out.println("********"+(instance3 == instance4));
        }
    }

}
